package daydayup.gateway.api.redis.listener;


import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;

public class RedisListener implements MessageListener {

	private RedisTemplate redisTemplate;
	
	@Override
	public void onMessage(Message message, byte[] pattern) {
		
		RedisSerializer redisSerializer = redisTemplate.getValueSerializer();
		
		String body= (String) redisSerializer.deserialize(message.getBody());
		
		System.out.println("reids监听成功!" + body);
		
	}

	public RedisTemplate getRedisTemplate() {
		return redisTemplate;
	}

	public void setRedisTemplate(RedisTemplate redisTemplate) {
		this.redisTemplate = redisTemplate;
	}

	

}
